//***********************************************************************
//	File:		Raider.cpp
//	Author:		
//	Course:		SGP 1405
//	Purpose:	
//***********************************************************************
//***********************************************************************
//	Purposfully left blank for all comments regarding this file 
//	
//	
//	
//***********************************************************************



#include "Raider.h"


Raider::Raider(float posX, float posY)
{
	SetAcceleration({ 0 , 0 }); 
	SetAttackCDL(.5f); 
	SetAttackRange(500); 
	SetConfuseCDL(4); 
	SetConfuseTimer(0); 
	SetDynamicFrictionCoefficient(.4f); 
	SetHealth(100); 
	//SetImage();
	SetKnockbackCDL(4); 
	SetKnockBackTimer(0);
	SetMass(90); 
	SetMaxHealth(100);
	SetMaxSpeed(100);
	SetNextAttack(0);
	SetPassable(false);
	SetPosition(SGD::Point{ posX, posY }); 
	SetProjectileType(ENT_BULLET); 
	SetRootCDL(4); 
	SetRootTimer(0); 
	SetRotation(0);
	SetSize(SGD::Size{ 64,64 }); 
	SetSpeed(0);
	SetStaticFrictionCoefficient(.7f);
	//SetTakeDamage() particle emitter
	SetTarget(nullptr); 
	SetValue(ENT_RAIDER);
	SetVelocity(SGD::Vector{ 0, -1 }); 

	m_hImage = SGD::GraphicsManager::GetInstance()->LoadTexture(
		L"reources/graphics/Raider.png");

}

//Interface
void Raider::Update(float dt)
{

	if (m_bMove == true)
	{
		
		if (pTarget)
		{
			SGD::Vector vec = pTarget->GetPosition() - GetPosition();
			vec.Normalize();
			vec *= 75.0f;

			SetPosition(GetPosition() + vec * dt);
		}

		
		if (pTarget->GetPosition().x - this->GetPosition().x <= 300 && pTarget->GetPosition().y - this->GetPosition().y <= 300)
			Attack(dt);

		if (m_fAttackCDL <= 0)
			m_fAttackCDL -= dt;

	}

	//Last line of function
	Entity::Update(dt); 
}

void Raider::Render()
{
	SGD::GraphicsManager::GetInstance()->DrawTexture(m_hImage, GetPosition(), 0.0, SGD::Vector(0, 0), SGD::Color(), SGD::Size(64, 64));
}

void Raider::HandleCollision(const IEntity* pOther)
{
	Entity::HandleCollision(pOther);
}

void Raider::HandleEvent()
{

}

SGD::Rectangle Raider::GetRect() const
{
	return SGD::Rectangle{}; 
}

void Raider::ModifyHealth(float hpAmount)
{
	m_fTotalHP -= hpAmount;
}

void Raider::ApplyFriction(float dt)
{

}

void Raider::Attack(float dt)
{
	if (pTarget->GetPosition().x - this->GetPosition().x <= 200 && pTarget->GetPosition().y - this->GetPosition().y <= 200)
	{

		if (m_fAttackCDL <= 0)
		{

			GetDamage();
			m_fAttackCDL = 10;

		}

	}
}

void Raider::Move(void)
{

}

//Raider specific 
void Raider::Shoot()
{

}